<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/assets/css/layui.css">
    <title>广告管理</title>
</head>
<body>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>上传视频</legend>
    </fieldset>
    <div class="layui-form-item" id="videoUp">
        <label class="layui-form-label" style="height: 137px; line-height: 117px">视频</label>
        <div class=" layui-upload-drag" id="video" style="border-left: 0px;" type="video">
            <i class="layui-icon">&#xe654;</i>
            <p>点击上传</p>
            <video id="demo9" src="" style="position: absolute;height: 137px;width: 137px;margin: -106px auto auto -60px;"/>
        </div>
    </div>
</body>
</html>
<script src="/static/assets/layui.all.js"></script>
<script src="/static/assets/jquery.min.js"></script>
<script src="/static/assets/limit.js"></script>
<script>
    layui.use('upload',function() {
        var $ = layui.jquery
            , upload = layui.upload;
        var uploadInst = upload.render({
            elem: '#video'
            , url: '/upload/show' //改成您自己的上传接口
            , accept: 'video'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo9').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                console.log(res)
                //如果上传失败
                if (res.code === 0) {
                    return layer.msg('上传失败');
                }
                imgs = res.data.filePath
                //上传成功
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    })

</script>